package com.wxq.koland.xiaoliscan;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.widget.RadioButton;
import android.widget.TextView;

import com.wxq.koland.xiaoliscan.bean.UserInfo;
import com.wxq.koland.xiaoliscan.utils.CheckUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ShowInfoActivity extends AppCompatActivity {

    @BindView(R.id.succeed_tv)
    TextView succeedTv;
    @BindView(R.id.booked)
    TextView booked;
    @BindView(R.id.my_info_tv)
    TextView myInfoTv;
    @BindView(R.id.name_tv)
    TextView nameTv;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.sex_tv)
    TextView sexTv;
    @BindView(R.id.sex)
    TextView sex;
    @BindView(R.id.phone_tv)
    TextView phoneTv;
    @BindView(R.id.phone)
    TextView phone;
    @BindView(R.id.count_tv)
    TextView countTv;
    @BindView(R.id.count)
    TextView count;
    @BindView(R.id.temperature_tv)
    TextView temperatureTv;
    @BindView(R.id.temperature)
    TextView temperature;
    @BindView(R.id.radio)
    RadioButton radio;



    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_info);
        ButterKnife.bind(this);
        timer.start();
        getData();
    }

    private void getData(){
        if (getIntent().hasExtra("userInfo")){
            Bundle b = getIntent().getBundleExtra("userInfo");
            name.setText(CheckUtil.getHintText(b.getString("userName"),1));
            phone.setText(CheckUtil.getHintText(b.getString("phone"),7));
            if (!b.getString("temperature").equals("")){
                String t = b.getString("temperature")+"°C" ;
                temperature.setText(t);
            }
            if ( b.getInt("set")==1){
                sex.setText("男");
            }else {
                sex.setText("女");
            }
            if (b.getInt("count")>0){
                count.setText(""+b.getInt("count"));
            }
        }
    }



    CountDownTimer timer = new CountDownTimer(3*1000,1000) {
        @Override
        public void onTick (long millisUntilFinished) {

        }

        @Override
        public void onFinish () {
            finishThis();
        }
    };

    private void finishThis(){
        if (timer!=null){
            timer.cancel();
            timer =null;
            finish();
        }
    }
}
